{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
		<article>
			<div class="content">
				<div class="instructions">
					<dl>
						<dt>地区管理</dt>
						<dd>
							各个地区的记录<br>
							点击显示下级地区。
						</dd>
					</dl>
					<a href="/admin/systems/area_add"><button type="button" class="button">添加地区</button></a>
				</div>
				<style type="text/css">
				</style>
				<table class="table">
					<!-- 控制表格宽度  横向合并 colspan="1"  竖向合并 rowspan="3" -->
					<thead><th>ID</th><th>名称</th><th>等级</th><th>上级id</th><th>操作</th></thead>
					{{range .info}}
					<tr id="{{.id}}" class="province" status="0">
						<td class="center">{{.id}}</td>
						<td class="center">{{.name}}</td>
						<td class="center">{{.level}}</td>
						<td class="center">{{.pid}}</td>
						<td class="center"><a href="/admin/systems/area_edit?id={{.id}}">编辑</a></td>
					</tr>
						{{range .city}}
						<tr pid="{{.pid}}" class="city" id="{{.id}}" status="0" style="display: none;">
							<td class="center">{{.id}}</td>
							<td class="center">├{{.name}}</td>
							<td class="center">{{.level}}</td>
							<td class="center">{{.pid}}</td>
							<td class="center"><a href="/admin/systems/area_edit?id={{.id}}">编辑</a></td>
						</tr>
							{{range .area}}
							<tr pid="{{.pid}}" class="area" style="display: none;">
								<td class="center">{{.id}}</td>
								<td class="center">├├{{.name}}</td>
								<td class="center">{{.level}}</td>
								<td class="center">{{.pid}}</td>
								<td class="center"><a href="/admin/systems/area_edit?id={{.id}}">编辑</a></td>
							</tr>
							{{end}}
						{{end}}
					{{end}}

					{{if ne .paginator.totalpages 1}}
					<tr>
						<td colspan="5">
							<div class="paging">
								{{if ne .paginator.currpage 1}}
								<a href="{{$.url}}page={{.paginator.firstpage}}">首页</a>
								<a href="{{$.url}}page={{.paginator.prevpage}}">&lt;&lt;</a>
								{{else}}
								<a class="disable">首页</a>
								<a class="disable">&lt;&lt;</a>
								{{end}}
								{{range $index,$page := .paginator.pages}}
								{{if eq $.paginator.currpage $page}} 
								<a class="no">{{$page}}</a>
								{{else}}
								<a href="{{$.url}}page={{$page}}">{{$page}}</a>
								{{end}}
								{{end}}
								{{if eq .paginator.currpage .paginator.totalpages}}
								<a class="disable">&gt;&gt;</a>
								<a class="disable">尾页</a>
								{{else}}
								<a href="{{$.url}}page={{.paginator.nextpage}}">&gt;&gt;</a>
								<a href="{{$.url}}page={{.paginator.totalpages}}">尾页</a>
								{{end}}
							</div>
						</td>
					</tr>
					{{end}}
				</table>
			</div>
			<!-- 系统配置 -->
		</article>
	</section>

<footer><!-- 系统监控内容 --></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script type="text/javascript">
	$('.province').click(function(){
		var id=$(this).attr('id')
		var status=$(this).attr('status')
		if (status==0){
			$('tr[pid='+id+']').css('display','table-row')
			$(this).attr('status','1')
		}else{
			$('tr[pid='+id+']').css('display','none')
			$(this).attr('status','0')
			$('tr[pid='+id+']').each(function(){
				var id2=$(this).attr("id")
				$('tr[pid='+id2+']').css('display','none')
			})
		}
	})
	$('.city').click(function(){
		var id=$(this).attr('id')
		var status=$(this).attr('status')
		if (status==0){
			$(this).attr('status','1')
			$('tr[pid='+id+']').css('display','table-row')
		}else{
			$(this).attr('status','0')
			$('tr[pid='+id+']').css('display','none')
		}
	})
</script>
</body>
</html>
